!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>个人工作中心</title>
    <link rel="stylesheet" href="css/font-awesome.min.css"/>
    <link rel="stylesheet" href="css/font-awesome-ie7.min.css"/>
    <link rel="stylesheet" href="css/bootstrap.min.css"/>
    <link href="css/jquery.datetimepicker.css" rel="stylesheet">
    <link rel="stylesheet" href="css/admin.css"/>

    <link rel="stylesheet" type="text/css" href="css/paging.css">

    <!--[if lt IE 9]>
    <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <![endif]-->
    <!--[if lt IE 10]>
    <script src="http://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/jquery-placeholder/2.0.8/jquery.placeholder.min.js"></script>
    <![endif]-->
</head>
<body>
<!-- 添加开始 -->
<div id="franchiseDiadog" class="diadog" style="width: 800px;">
    <div class="diadog-tit" style="width: 100%">
        <div class="row">
            <div id="diadogTit" class="col-md-11"><span>订单跟踪记录</span></div>
            <div class="col-md-1 close"><span>×</span></div>
        </div>
    </div>
    <div class="diadog-con" style="width: 100% !important;padding-right: 30px;">
        <div class="form-horizontal" role="form">
            <div class="form-group">
                <label for="inputEmail3" class="col-sm-2 control-label" style="width: 130px !important;">记录列表:</label>
                <div class="col-sm-10" style="width: 670px !important;">
                    <ul id="typeList" style="margin-top: 8px">

                    </ul>
                </div>
            </div>
            <div id="stepMemonone" class="form-group">
                <label for="inputPassword3" class="col-sm-2 control-label"  style="width: 130px !important;"><span
                        style="color: #e4393c">*</span>添加记录:</label>
                <div class="col-sm-10" style="width: 670px !important;">
                    <textarea id="stepMemo" class="form-control" rows="3"></textarea>
                </div>
            </div>
            <div id="addUserSurenone" class="form-group">
                <div style="margin-left: 125px">
                    <button id="addUserSure" type="submit" class="btn btn-primary">确定增加</button>
                </div>
            </div>
        </div>
    </div>
</div>
<!--添加结束-->
<div id="gray_bg"></div>
<!-- 删除订单结束 -->
<!-- header start -->
<div id="header" class="header">

</div>
<!-- header end -->
<!-- usercenter start -->
<div class="usercotent">
    <div id="center-left"></div>
    <div class="usercotentr floatr">
        <div class="user-tit" style="margin-bottom:10px">
            <h3>个人工作中心</h3>
        </div>
        <div class="usercotent-con">
            <div class="countList">
                <ul>
                    <a href="work-my.html"><li style="background-color: #dd4b39 !important;">
                        <div class="countList-l"><i class="fa  icon-time"></i></div>
                        <div class="countList-r"><span style="line-height: 30px;font-size: 16px">跟踪时间未超时订单数量</span><br><span id="supportList" style="font-size: 38px;font-weight: bold;white-space: nowrap;"></span></div>
                    </li></a>
                    <a href="order-alreadyCompleted.html"><li style="margin-left:4%;background-color: #00a65a !important">
                        <div class="countList-l"><i class="fa icon-thumbs-up"></i></div>
                        <div class="countList-r"><span style="line-height: 30px;font-size: 16px">已完成订单数量</span><br><span id="completeCount" style="font-size: 38px;font-weight: bold;white-space: nowrap;"></span></div>
                    </li></a>
                    <a href="order-alreadyAccepted.html"><li style="margin-left:4%;background-color: #f39c12 !important;">
                        <div class="countList-l"><i class="fa  icon-bookmark-empty"></i></div>
                        <div class="countList-r"><span style="line-height: 30px;font-size: 16px">已受理订单数量</span><br><span id="accept" style="font-size: 38px;font-weight: bold;white-space: nowrap;"></span></div>
                    </li></a>

                    <a href="user-orderPending.html"><li style="margin-left:4%;background-color: #00c0ef !important;">
                        <div class="countList-l"><i class="fa  icon-refresh"></i></div>
                        <div class="countList-r"><span style="line-height: 30px;font-size: 16px">待受理订单数量</span><br><span id="unacceptableCount" style="font-size: 38px;font-weight: bold;white-space: nowrap;"></span></div>
                    </li></a>
                </ul>
            </div>


            <div class="down">
                <div class="overtime" style="padding-bottom: 20px">跟踪时间未超时订单明细</div>
                <table class="table table-bordered table-hover table-condensed">
                    <thead>
                    <tr>
                        <th>操作</th>
                        <th>订单类型</th>
                        <th>订单名称</th>
                        <th>所属门店</th>
                        <th>业务人员</th>
                        <th>订单金额</th>
                        <th>联系人</th>
                        <th>联系电话</th>
                        <th>下单时间</th>
                        <th>受理人</th>
                        <th>受理时间</th>
                        <th>订单备注</th>
                    </tr>
                    </thead>
                    <tbody id='result'>
                    </tbody>
                    </table>
            </div>
            <!-- page start -->
            <nav class="totalpage floatr">
                <span>总共</span><strong id="totalpage"></strong><span>条</span>
            </nav>
            <div class="clear"></div>
            <!-- page end -->
        </div>

    </div>
    <div class="clear"></div>
</div>

<!-- usercenter end -->

<!-- footer start -->
<div class="footer">
    <div class="bot">
        <p style="padding-top: 10px; text-align: center">Copyright (C) 都能印 2014-2016, all Rights Reserved | 豫ICP备14024464号-1 | 增值电信业务经营许可证：豫B2-20150019</p>
        <p class="authentication" style="padding-bottom: 10px; padding-top: 10px;">
            <img src="img/footer1.png" alt="">
            <img src="img/footer2.png" alt="">
            <img src="img/footer3.png" alt="">
            <img src="img/footer4.png" alt="">
            <img src="img/footer5.png" alt="">
        </p>
    </div>
</div>
<!-- footer end -->
<script src="js/jquery.min-1-11-3.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/widget/myDataGrid.js"></script>
<script src="js/widget/admin.js"></script>
<script type="text/javascript" src="js/query.js"></script>
<script type="text/javascript" src="js/paging.js"></script>
<script type="text/javascript">
    //开始
    $(function () {
        initSideAccMenu("工作中心","个人工作中心");



        //个人中心
        var url="apis/wx/getUserLoginIndex";
        var data={
            "params":{}
        };
        var jsonData = JSON.stringify(data);
        $.ajax({
            url:url,
            type:'post',
            data: jsonData,
            dataType:'json',
            contentType : 'application/json',
            success:function (res) {
//                console.log(res);

                if(res.httpCode == 200){
                    $("#completeCount").html(res.data.completeCount);
                    $("#accept").html(res.data.acceptedCount);
                    $("#unacceptableCount").html(res.data.unacceptableCount);
                    var companyList = res.data.supportList;
                    if(companyList.length<=0){
                       $(".totalpage").hide();
                        $("#totalpage").html("0");
                        $("#supportList").html("0");
                        var html = "<tr>"+"<th colspan='11'><h3>暂时没有数据</h3></th>"+"</tr>";
                        $("#result").append(html);
                    }else {
                        $("#totalpage").html(companyList.length);
                        $("#supportList").html(companyList.length);
                        var html = "";
                        for(var i=0 ; i < companyList.length; i++){

                            var companyLists =companyList[i];
                            html += mkDiv(companyLists);
                        }
                        $("#result").append(html);
                    }

                }
                else{
                    alert(res.msg);
                }
            },
            error:function (res) {
                alert(res.msg);
            }
        })
        //关闭
        $(".close,#deleteCancle").click(function () {
            $("#gray_bg").hide();
            $("#franchiseDiadog").hide();
            $("#deleteDiadog").hide();
        });
        //订单跟踪记录添加
        $("#addUserSure").click(function () {
            var stepMemo = $("#stepMemo").val();
            if(!stepMemo){
                alert("请添加订单跟踪记录");
                return;
            }
            var url="apis/wx/recordOrderStep";
            var data={
                "idOrder":id,
                "stepMemo":stepMemo

            };
            var jsonData = JSON.stringify(data);
            //console.log(jsonData);
            $.ajax({
                url:url,
                type:'post',
                data: jsonData,
                dataType:'json',
                contentType : 'application/json',
                success:function (res) {


                    if(res.httpCode == 200){
                        $("#franchiseDiadog").hide();
                        $("#gray_bg").hide();
                        alert("成功");
                        window.location.reload();//刷新当前页面.
                    }
                    else{
                        alert(res.msg);
                    }
                },
                error:function (res) {
                    alert(res.msg);
                }
            })

        });

    })
    //end
    //订单跟踪弹出
    function toStep(e) {
        $("#stepMemo").val("");
        id=e;
        $("#typeList").empty();
        $("#gray_bg").css({"height": $(document).height()});
        $("#franchiseDiadog").show();
        $("#gray_bg").show();
        $("#franchiseDiadog").center();
        var url="apis/wx/getOrderStepByOrder";
        var data={
            "idOrder":id
        };
        var jsonData = JSON.stringify(data);
        //console.log(jsonData);
        $.ajax({
            url:url,
            type:'post',
            data: jsonData,
            dataType:'json',
            contentType : 'application/json',
            success:function (res) {
                //console.log(res);
                var companyList = res.data;
                var html = "";
                if(companyList.length<=0){
                    html +="<li style='word-wrap:break-word;padding: 5px 0;border-bottom: 1px dotted #ddd; '>暂无订单跟踪记录</li>";
                }else {
                    for(var i=0 ; i < companyList.length; i++){

                        var companyLists =companyList[i];
                        html += mkDivStep(companyLists);
                    }
                }
                $("#typeList").append(html);

                if(res.httpCode == 200){
                }
                else{
                    alert(res.msg);
                }
            },
            error:function (res) {
                alert(res.msg);
            }
        })


    }
    //记录列表divstyle="word-wrap:break-word;"
    function mkDivStep(companyLists){
        var worktime = getTime(companyLists.worktime)
        var str = "<li style='word-wrap:break-word;padding: 5px 0;border-bottom: 1px dotted #ddd; '>"+"跟踪时间："+worktime+"&nbsp&nbsp&nbsp&nbsp"+"记录人："+companyLists.workmanname+"&nbsp&nbsp&nbsp&nbsp"+"跟踪内容："+companyLists.workmemo+"</li>"
        return str;
    }
    //结束
    //构造列表div
    function mkDiv(companyLists){
        var status = companyLists.ordertype;
        var stateStr = "";
        switch (status) {
            case 0:
                stateStr = "知识产权订单";
                break;
            case 1:
                stateStr = "印品订单";
                break;
            case 2:
                stateStr = "推荐合作订单";
                break;
            case 3:
                stateStr = "设计订单";
                break;
        }
        var str = "<tr>"+
                        "<td>"+"<a onclick=\"toStep(" + companyLists.id + ")\">跟踪记录</a>"+"</td>"+
                        "<td>"+stateStr+"</td>"+
                        "<td>"+getNullStr(companyLists.productname)+"</td>"+
                        "<td>"+getNullStr(companyLists.storename)+"</td>"+
                        "<td>"+getNullStr(companyLists.belongsname)+"</td>"+
                        "<td>"+getNullStr(companyLists.ordermoney)+"</td>"+
                        "<td>"+getNullStr(companyLists.customername)+"</td>"+
                        "<td>"+getNullStr(companyLists.customerphone)+"</td>"+
                        "<td>"+getTime(companyLists.createtime)+"</td>"+
                        "<td>"+getNullStr(companyLists.managename)+"</td>"+
                        "<td>"+getTime(companyLists.manageTime)+"</td>"+
                        "<td>"+getNullStr(companyLists.remark)+"</td>"+
                    "</tr>"

        return str;
    };
    //获取空字符串
    function getNullStr(str){
        var ts = arguments[0] || "";
        return ts;
    }
    //获取时间
    function getTime() {
        var ts = arguments[0] || 0;
        var t, y, m, d, h, i, s;
        t = ts ? new Date(ts) : new Date();
        y = t.getFullYear();
        m = t.getMonth() + 1;
        d = t.getDate();
        h = t.getHours();
        i = t.getMinutes();
        s = t.getSeconds();
        // 可根据需要在这里定义时间格式
        return y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d) + ' ' + (h < 10 ? '0' + h : h) + ':' + (i < 10 ? '0' + i : i) + ':' + (s < 10 ? '0' + s : s);
    }
    //center
    jQuery.fn.center = function () {
        this.css("position", "absolute");
        this.css("top", ( $(window).height() - this.height() ) / 2 + $(window).scrollTop() + "px");
        this.css("left", ( $(window).width() - this.width() ) / 2 + $(window).scrollLeft() + "px");
        return this;
    }

</script>
</body>
</html>